﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dukous.Search
{
    /// <summary>
    /// 搜索上下文接口
    /// </summary>
    public interface ISearchContext
    {
        /// <summary>
        /// 获取 内容类型
        /// </summary>
        string ContentType { get; }

        /// <summary>
        /// 获取 分页大小
        /// </summary>
        int PageSize { get; }

        /// <summary>
        /// 获取 当前页序号，下标从 1 开始
        /// </summary>
        int PageIndex { get; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        ISearchContext SetPageSize(int size);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        ISearchContext SetPageIndex(int index);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="value"></param>
        ISearchContext SetFilter(string fieldName, object value);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="minValue"></param>
        /// <param name="maxValue"></param>
        ISearchContext SetFilter(string fieldName, object minValue, object maxValue);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="filterName"></param>
        /// <returns></returns>
        T GetValue<T>(string filterName);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="filterName"></param>
        /// <returns></returns>
        T GetMinValue<T>(string filterName);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="filterName"></param>
        /// <returns></returns>
        T GetMaxValue<T>(string filterName);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="filterName"></param>
        /// <returns></returns>
        ISearchContext SetOrder(string filterName);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="filterName"></param>
        /// <param name="asc"></param>
        /// <returns></returns>
        ISearchContext SetOrder(string filterName, bool asc);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="filterName"></param>
        /// <returns></returns>
        SearchOrder GetOrder(string filterName);
    }
}
